/*
 *  Cero Project - Copyright   2006 The Cero Developement Team 
 *  (Michael Laguerre, Camille Roux, Matthieu Segret, Mathieu Sivade) 
 * 
 *  This program is free software; you can redistribute it and/or modify it 
 *  under the terms of the GNU General Public License as published by the Free 
 *  Software Foundation; either version 2 of the License, or (at your option) 
 *  any later version.
 * 
 *  This program is distributed in the hope that it will be useful, but 
 *  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 *  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
 *  for more details.
 */

package org.ceroproject.ui.graphical;

import javax.swing.*;
import javax.swing.plaf.metal.MetalLookAndFeel;

import org.ceroproject.ui.graphical.tools.base.DeckBase;

/**
 * This class creates the main frame of the GUI.
 * 
 * @author Michael Laguerre, Camille Roux
 */
public class Frame extends JFrame {

	/* -------------- field ------------- */

	/** serialVersionUID required for serializable interface */
	private static final long serialVersionUID = 3762256318450250038L;

	final JFrame frame = this;

	/**
	 * Build the Frame
	 * 
	 * @param name
	 *            the Frame's name
	 */
	public Frame(String name) {
		super(name);

		// frame configuration
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setSize(getMaximumSize()); // Maximize the window

		turnBoldFontsOff();

		// loading of the menu
		this.setJMenuBar(CeroMenuBar.getInstance());
		this.getContentPane().add(new DeckBase());
	}

	/**
	 * Turn off the ugly bold fonts
	 */
	private void turnBoldFontsOff() {
		// turn off bold fonts
		UIManager.put("swing.boldMetal", Boolean.FALSE);

		// re-install the Metal Look and Feel
		try {
			UIManager.setLookAndFeel(new MetalLookAndFeel());
		} catch (UnsupportedLookAndFeelException e) {
			e.printStackTrace();
		}
		// Update the ComponentUIs for all Components. This
		// needs to be invoked for all windows.
		SwingUtilities.updateComponentTreeUI(this);

	}

	public static void main(String[] args) {
		Frame f = new Frame("Cero Project");
		f.setVisible(true);
	}

}
